package com.yunwrite.playerdemo;

import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.yunwrite.playerlibrary.customplayer.videolist.VideoInfo;
import com.yunwrite.playerlibrary.customplayer.videolist.VideoInfoImp;
import com.yunwrite.playerlibrary.customplayer.view.CustomPlayerView;

import java.util.ArrayList;

/**
 * @author liuping
 */
public class MainActivity extends AppCompatActivity {

    private String url1 = "http://ybkcsmmovd.eboker.otvcloud.com/otv/ssports/6/7D/B2/00000083819/index.m3u8?rollId=11516&ts=1527157619803";
    private String url2 = "http://ybkcsmmovd.eboker.otvcloud.com/otv/ssports/7/5A/CF/00000083905/index.m3u8?rollId=16793&ts=1527181221520";
    private String url3 = "http://ybkcsmmovd.eboker.otvcloud.com/otv/yfy/B/3E/8D/00000083821/index.m3u8?rollId=16816&ts=1527157616064";
    private String url4 = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";

    private ArrayList<VideoInfo> list=new ArrayList<>();

    CustomPlayerView customPlayerView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            //申请WRITE_EXTERNAL_STORAGE权限
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
        }

        customPlayerView=findViewById(R.id.cpv);
        list.add(new VideoInfoImp(url1));
        list.add(new VideoInfoImp(url2));
        list.add(new VideoInfoImp(url3));
        list.add(new VideoInfoImp(url4));
        customPlayerView.getVideoListManager().insertVIdeoinfos(list);
    }
}
